﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DAL
{
    public partial class PAG0010CAR1
    {


        public void SetAddP(dbGespagDataContext _db,
                                    char tipoProveedor,  //P ->proveedor H->Recibo Honorario
                                    string ruc,
                                     string tipoDocumento,
                                     string numDocumento,
                                     DateTime fechaDocumento,
                                     DateTime fechaVencimiento,
                                     int diasVencimiento,
                                     DateTime fechaPago,
                                     int idMoneda,
                                      decimal tipoCambio,
                                     char tipoOrigen,
                                    string glosa,
                                     decimal totalDoc,
                                     decimal IGVDoc,
                                     decimal baseInafecto,
                                     decimal totalDocSOL,
                                     decimal totalDocDOL,
                                     decimal impISC,
                                     string usuarioStr,
                                     int idRecepcionDoc, 
                                    string centroCosto,
                                    string cuentaContable,
                                    string tipoProvicion,
                                    char tipoAnexo,
                                    string anexo)
        {



            this.CT1_CTIPANE = tipoProveedor;
            this.CT1_CCODANE = ruc;
            this.CT1_CCODSUC = "0001";
            this.CT1_CTIPDOC = tipoDocumento;
            this.CT1_CNUMDOC = numDocumento;
            this.CT1_CGLOSA = glosa; 



            string fechaDoc = fechaDocumento.ToString("yyyyMMdd");
            string fechaVen = fechaVencimiento.ToString("yyyyMMdd");
            string fechaPag = fechaPago.ToString("yyyyMMdd");
            string moneda = idMoneda == 3 ? "MN" : "US";

            this.CT1_CCODVEN = "";
            this.CT1_CSITUAC = "";

            this.CT1_DFECDOC = fechaDoc; //,	'20130115',
            this.CT1_DFECVEN = fechaVen;	//'20130131',
            this.CT1_DFECPAG = fechaPag;	//'20130115',
            this.CT1_CCODMON = moneda;	//'MN',
            this.CT1_NTIPCAM = tipoCambio;	//'2.55',




            this.CT1_NIMPORT = totalDoc;	//0,
            this.CT1_NSALDO = 0;	//0,
            this.CT1_NSALINI = 0;
            this.CT1_NIMPIGV = IGVDoc;	//'48',
            this.CT1_NIMPANG = baseInafecto;	//'1000',
            this.CT1_NIMPISC = impISC;	//'1800',
            this.CT1_NIMPDET = 0;	//'0'
            this.CT1_NBASDET = 0;	//'0',

            this.CT1_NIMPOMN = totalDocSOL;	//'0'
            this.CT1_NSALDMN = 0;	//'0',
            this.CT1_NSALIMN = 0;

            this.CT1_NIMPOUS = totalDocDOL;	//0',dolares
            this.CT1_NSALDUS = 0;	//'0',
            this.CT1_NSALIUS = 0;
            this.CT1_NIMPRET = 0;	//,'0',


            this.CT1_CTASDET = string.Empty;	//'',





            //this.CT1_NIMPPER=0;	//'0',
            this.CT1_CSUBDIA = string.Empty;	//'',
            this.CT1_CCOMPRO = string.Empty;	//'',

            this.CT1_CANOCOM = fechaDocumento.Year.ToString();	//'2013',
            this.CT1_CTIPCOM = "COM";	//'COM',
            this.CT1_CCTACOM = "";	//'',
            this.CT1_CORIGEN = tipoOrigen;	//'M',
            this.CT1_CDEBHAB = tipoDocumento == "NC" ? 'D' : 'H';	//'H',  //solo si es nota Credito
            this.CT1_CESTADO = 'A';	//'R',

            this.CT1_NDIAVEN = diasVencimiento;	//'15',
            this.CT1_CCENCOS = string.Empty; ;	//'',
            this.CT1_CDATADI = string.Empty;	//'',
            this.CT1_CAREREF = string.Empty;	//'',
            this.CT1_CANEREF = ' ';	//'',
            this.CT1_CCODREF = string.Empty;	//'',
            this.CT1_CSUCREF = string.Empty;	//'',
            this.CT1_CDOCREF = string.Empty;	//'',
            this.CT1_CNUMREF = string.Empty;	//'',
            this.CT1_CTIANPR = ' ';	//'',
            this.CT1_CANEPRI = string.Empty;	//'',
            this.CT1_CTIANAU = ' ';	//'',
            this.CT1_CANEAUX = string.Empty;	//'',
            this.CT1_CDATREF = string.Empty;	//'',





            string fecha = DateTime.Now.ToString("yyyyMMdd");
            string hora = String.Format("{0:h:mm}", DateTime.Now);
            string hora2 = String.Format("{0:mm:ss}", DateTime.Now);


            this.CT1_DFECMOD = fecha; //	'20121206',
            this.CT1_CHORMOD = hora; //	'13:37',
            this.CT1_CUSUMOD = usuarioStr; //	'sist',
            this.CT1_CUSUCRE = usuarioStr; //	'sist',
            this.CT1_DFECCRE = fecha; //	'20121206',
            this.CT1_CHORCRE = hora; //	'13:37'



            this.CT1_CTIDOAP = string.Empty;
            this.CT1_CNUDOAP = string.Empty;
            this.CT1_DFEDOAP = string.Empty;

            this.CT1_CNRODET = string.Empty;
            this.CT1_DFECDET = string.Empty;
            this.CT1_CSUCCAN = string.Empty;
            this.CT1_CTIPCAN = string.Empty;
            this.CT1_CNUMCAN = string.Empty;
            this.CT1_CBANCAN = string.Empty;
            this.CT1_CDATEXT = idRecepcionDoc.ToString();

            this.CT1_COBSERV = string.Empty;
            this.CT1_CSECCAN = string.Empty;



            //-----------------ultimos cambios en DB------------------------------
            this.CT1_CCENCOS = centroCosto; ;	//'',
            this.CT1_CDATADI = centroCosto;	//'',
            if (tipoAnexo == 'T')
            {
                this.CT1_CCTACOM = cuentaContable;	//'cuenta contable/compra 141542--> vaucher de provision  matricular en tabla',
                this.CT1_CTIANAU = tipoAnexo;	//tipo anexo auxiliar' T/-->tabla general',
                this.CT1_CANEAUX = anexo;	//'',
                this.CT1_CDATREF = "CAJ";// ;	//'CAJ,COM,HON,VAR,REN CUENTA',

            }
            else
            {
                this.CT1_CCTACOM = "";	//'cuenta contable/compra 141542--> vaucher de provision  matricular en tabla',
                this.CT1_CTIANAU = ' ';	//tipo anexo auxiliar' T/-->tabla general',
                this.CT1_CANEAUX = "";	//'',
                this.CT1_CDATREF = "COM";// ;	//'CAJ,COM,HON,VAR,REN CUENTA',

            }
            //------------


            _db.PAG0010CAR1s.InsertOnSubmit(this);















































        }





        public void SetAddH(dbGespagDataContext _db,
                                   string ruc,
                                    string tipoDocumento,
                                    string numDocumento,
                                    DateTime fechaDocumento,
                                    DateTime fechaVencimiento,
                                    int diasVencimiento,
                                    DateTime fechaPago,
                                    int idMoneda,
                                     decimal tipoCambio,
                                    char tipoOrigen,
                                    string glosa,
                                    decimal importeNeto,
                                    decimal importeNetoMN,
                                    decimal importeNetoUS,
                                    decimal Renta4ta,
                                    string usuarioStr,
                                    int idRecepcinoDoc, string centroCosto,
                                    string cuentaContable,
                                    string tipoProvicion,
                                    char tipoAnexo,
                                    string anexo)
        {


            this.CT1_CTIPANE = 'H';
            this.CT1_CCODANE = ruc; //RH
            this.CT1_CCODSUC = "0001";
            this.CT1_CTIPDOC = tipoDocumento;
            this.CT1_CNUMDOC = numDocumento;

            string fechaDoc = fechaDocumento.ToString("yyyyMMdd");
            string fechaVen = fechaVencimiento.ToString("yyyyMMdd");
            string fechaPag = fechaPago.ToString("yyyyMMdd");
            string moneda = idMoneda == 3 ? "MN" : "US";

            this.CT1_CCODVEN = "";
            this.CT1_CSITUAC = "";

            this.CT1_DFECDOC = fechaDoc; //,	'20130115',
            this.CT1_DFECVEN = fechaVen;	//'20130131',
            this.CT1_DFECPAG = fechaPag;	//'20130115',
            this.CT1_CCODMON = moneda;	//'MN',
            this.CT1_NTIPCAM = tipoCambio;	//'2.55',

            this.CT1_NIMPORT = importeNeto;	//0,
            this.CT1_NSALDO = 0;	//0,
            this.CT1_NSALINI = 0;
            this.CT1_NIMPIGV = 0;	//'48',
            this.CT1_NIMPANG = 0;	//'1000',
            this.CT1_NIMPISC = 0;	//'1800',
            this.CT1_NIMPDET = 0;	//'0'
            this.CT1_NBASDET = 0;	//'0',

            this.CT1_NIMPOMN = importeNetoMN;	//'0' se base en el importe neto
            this.CT1_NSALDMN = 0;	//'0',
            this.CT1_NSALIMN = 0;

            this.CT1_NIMPOUS = importeNetoUS;	//0',dolares
            this.CT1_NSALDUS = 0;	//'0',
            this.CT1_NSALIUS = 0;
            this.CT1_NIMPRET = Renta4ta;	//,'0',


            //--------------

            this.CT1_CTASDET = string.Empty;	//'',

            this.CT1_CSUBDIA = string.Empty;	//'',
            this.CT1_CCOMPRO = string.Empty;	//'',

            this.CT1_CANOCOM = fechaDocumento.Year.ToString();	//'2013',
            this.CT1_CTIPCOM = "HON";	//'COM',
            this.CT1_CCTACOM = "";	//'',
            this.CT1_CORIGEN = tipoOrigen;	//'M',
            this.CT1_CDEBHAB = 'H';	//'H',
            this.CT1_CESTADO = 'A';	//'R',

            this.CT1_NDIAVEN = diasVencimiento;	//'15',
            this.CT1_CCENCOS = string.Empty; ;	//'',
            this.CT1_CDATADI = string.Empty;	//'',
            this.CT1_CAREREF = string.Empty;	//'',
            this.CT1_CANEREF = ' ';	//'',
            this.CT1_CCODREF = string.Empty;	//'',
            this.CT1_CSUCREF = string.Empty;	//'',
            this.CT1_CDOCREF = string.Empty;	//'',
            this.CT1_CNUMREF = string.Empty;	//'',
            this.CT1_CTIANPR = ' ';	//'',
            this.CT1_CANEPRI = string.Empty;	//'',
            this.CT1_CTIANAU = ' ';	//'',
            this.CT1_CANEAUX = string.Empty;	//'',
            this.CT1_CDATREF = string.Empty;	//'',


            string fecha = DateTime.Now.ToString("yyyyMMdd");
            string hora = String.Format("{0:h:mm}", DateTime.Now);
            string hora2 = String.Format("{0:mm:ss}", DateTime.Now);


            this.CT1_DFECMOD = fecha; //	'20121206',
            this.CT1_CHORMOD = hora; //	'13:37',
            this.CT1_CUSUMOD = usuarioStr; //	'sist',
            this.CT1_CUSUCRE = usuarioStr; //	'sist',
            this.CT1_DFECCRE = fecha; //	'20121206',
            this.CT1_CHORCRE = hora; //	'13:37'



            this.CT1_CTIDOAP = string.Empty;
            this.CT1_CNUDOAP = string.Empty;
            this.CT1_DFEDOAP = string.Empty;

            this.CT1_CNRODET = string.Empty;
            this.CT1_DFECDET = string.Empty;
            this.CT1_CSUCCAN = string.Empty;
            this.CT1_CTIPCAN = string.Empty;
            this.CT1_CNUMCAN = string.Empty;
            this.CT1_CBANCAN = string.Empty;
            this.CT1_CGLOSA = centroCosto + '-' + glosa; 
            this.CT1_CDATEXT = idRecepcinoDoc.ToString();


            this.CT1_COBSERV = string.Empty;
            this.CT1_CSECCAN = string.Empty;


            //-----------------ultimos cambios en DB------------------------------
            this.CT1_CCENCOS = centroCosto; ;	//'',
            this.CT1_CDATADI = centroCosto;	//'',
            if (tipoAnexo == 'T')
            {
                this.CT1_CCTACOM = cuentaContable;	//'cuenta contable/compra 141542--> vaucher de provision  matricular en tabla',
                this.CT1_CTIANAU = tipoAnexo;	//tipo anexo auxiliar' T/-->tabla general',
                this.CT1_CANEAUX = anexo;	//'',
                this.CT1_CDATREF = "CAJ";// ;	//'CAJ,COM,HON,VAR,REN CUENTA',

            }
            else
            {
                this.CT1_CCTACOM = "";	//'cuenta contable/compra 141542--> vaucher de provision  matricular en tabla',
                this.CT1_CTIANAU = ' ';	//tipo anexo auxiliar' T/-->tabla general',
                this.CT1_CANEAUX = "";	//'',
                this.CT1_CDATREF = "COM";// ;	//'CAJ,COM,HON,VAR,REN CUENTA',

            }
            //------------


            _db.PAG0010CAR1s.InsertOnSubmit(this);

        }
    }
}